/*
 * @Author: zingpp
 * @Date: 2025-06-19 17:44:45
 * @LastEditors: zingpp
 * @LastEditTime: 2025-06-19 17:57:11
 * @FilePath: \cool-server\src\app.service.ts
 * @Description:
 *
 * Copyright (c) 2025 by 用户/公司名, All Rights Reserved.
 */
import { Injectable } from '@nestjs/common';
import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';

@Injectable()
export class AppService {
  constructor(private eventEmitter: EventEmitter2) {}

  getHello(): string {
    this.eventEmitter.emit('app.hello', { message: 'Hello Event!' });
    return 'Hello World!';
  }

  @OnEvent('app.hello')
  handleHelloEvent(payload: any) {
    console.log('Received event:', payload);
  }
}
